// components/nav-tab/index.ts
let app = getApp()
Component({
  /**
   * 组件的属性列表
   */
  properties: {
    list: {
      type: Array,
      value: [
        // {name: '首页', value: 1, img: '', url: '/pages/index/index'},
        // {name: '预约', value: 2, img: '', url: '/pages/pre-book/index'},
        // {name: '我的', value: 3, img: '', url: '/pages/mine/index'},
      ],
      observer(val){
        this.setData({
          showList: val
        })
      }
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    showList: [],
    curIndex: 1,
  },
  attached(){
    this.setData({
      curIndex: app.globalData.tarCurIndex
    })
  },
  /**
   * 组件的方法列表
   */
  methods: {
    onClick(e){
      let data = e.currentTarget.dataset
      this.setData({
        curIndex: data.id
      })
      app.globalData.tarCurIndex = data.id
      wx.redirectTo({
        url: data.url,
      })
    },
  }
})
